home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / dirent.lha / dirent / sys.dirent.h < prev    next >
C/C++ Source or Header  |  1988-10-10  |  1KB  |  40 lines

  1. /*
  2.     <sys/dirent.h> -- file system independent directory entry (SVR3)
  3.  
  4.     last edit:    13-Oct-1987    D A Gwyn
  5.  
  6.     prerequisite:    <sys/types.h>
  7. */
  8.  
  9. struct dirent                /* data from getdents()/readdir() */
  10.     {
  11.     long        d_ino;        /* inode number of entry */
  12.     off_t        d_off;        /* offset of disk directory entry */
  13.     unsigned short    d_reclen;    /* length of this record */
  14.     char        d_name[1];    /* name of file */    /* non-POSIX */
  15.     };
  16.  
  17. #ifdef BSD_SYSV                /* (e.g., when compiling getdents.c) */
  18. extern struct dirent    __dirent;    /* (not actually used) */
  19. /* The following is portable, although rather silly. */
  20. #define    DIRENTBASESIZ        (__dirent.d_name - (char *)&__dirent.d_ino)
  21.  
  22. #else
  23. /* The following nonportable ugliness could have been avoided by defining
  24.    DIRENTSIZ and DIRENTBASESIZ to also have (struct dirent *) arguments.
  25.    There shouldn't be any problem if you avoid using the DIRENTSIZ() macro. */
  26.  
  27. #define    DIRENTBASESIZ        (((struct dirent *)0)->d_name \
  28.                 - (char *)&((struct dirent *)0)->d_ino)
  29. #endif
  30.  
  31. #define    DIRENTSIZ( namlen )    ((DIRENTBASESIZ + sizeof(long) + (namlen)) \
  32.                 / sizeof(long) * sizeof(long))
  33.  
  34. /* DAG -- the following was moved from <dirent.h>, which was the wrong place */
  35. #define    MAXNAMLEN    512        /* maximum filename length */
  36.  
  37. #ifndef NAME_MAX
  38. #define    NAME_MAX    (MAXNAMLEN - 1)    /* DAG -- added for POSIX */
  39. #endif
  40.